<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1.0, user-scalable=no"/>
  <title>系统登录</title>
  <link rel="stylesheet" href="../styles/login.css">
  <script src="../js/vue.js"></script>
  <script src="../js/axios-0.18.0.js"></script>
  <script src="../element-ui/lib/index.js"></script>
  <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">

  <style>
      .el-input__inner {
          font-size: 20px;
          height: 50px;
          background: transparent !important;
      }

      .el-input__inner::placeholder {
          color: gray;
      }
  </style>
</head>
<body id="bgc">

<div id="app">
  <h1 style="color: black">后台登录</h1>
  <el-input id="username" v-model="username" prefix-icon="el-icon-user" placeholder="请输入用户名" clearable></el-input>
  <div style="margin: 30px 0;"></div>
  <el-input prefix-icon="el-icon-lock" placeholder="请输入密码" v-model="password" show-password
            @keyup.enter.native="handleLogin()"></el-input>
  <div style="margin: 30px 0;"></div>
  <button @click="handleLogin()">登录</button>
</div>
<script src="/backend/plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="/backend/plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="/backend/plugins/axios/axios.min.js"></script>
<script src="/backend/js/request.js"></script>
<script src="/backend/api/login.js"></script>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                username: '',
                password: ''
            }
        },
        methods: {
            async handleLogin() {
                const param = {
                    username: this.username,
                    password: this.password
                }
                let res = await loginApi(param)
                if (String(res.code) === '1') { //1表示登陆成功
                    window.localStorage.setItem('adminInfo', JSON.stringify(res.data))//放json
                    window.location.href = '/backend/index.html'//跳转
                } else {
                    this.$message.error(res.msg)
                }
            }


        }
    })
</script>

</body>
</html>